<?php
error_reporting(0);
session_start();

include_once "src/model/Consultant.php";
include_once "src/controller/regmanagement/AccountManager.php";
include_once "src/controller/regmanagement/MiscellaneousManager.php";
include_once "src/model/ProvidedService.php";

try {
    $months = array();
    $months["0"] = "q";
    $months["01"] = "January";
    $months["02"] = "February";
    $months["03"] = "March";
    $months["04"] = "April";
    $months["05"] = "May";
    $months["06"] = "June";
    $months["07"] = "July";
    $months["08"] = "August";
    $months["09"] = "September";
    $months["10"] = "October";
    $months["11"] = "November";
    $months["12"] = "December";

    $user = AccountManager::getConsultant($_GET["email"]);
} catch (Exception $e) {
    echo $e->getMessage();
}
?>
<link href="styles/default.css"
      rel="stylesheet"
      type="text/css"
      media="all">

<style>
    html, body {
        margin: 0px;
        padding: 5px;
    }
</style>

<table border="0" 
       cellpadding="0"
       cellspacing="0"
       width="750"
       style="border:1px solid #CCCCCC;">
    <tbody>
        <tr>
            <td style="width:30px;background-image:url('images/dialogBg.png');background-repeat:repeat-y;"></td>
            <td align="center"
                valign="top"
                id="consultantDetailInformationDialogArea">
                <div style="padding-top:3px;padding-right:10px;text-align:right;padding-top:10px;">
                    <a onclick="window.close();" style="cursor:pointer;">
                        <img src="images/icons/closeIcon.jpg" width="20" alt="closeIcon"/>
                    </a>
                </div>
                <div style="background-color:#FFFFFF;font-family:Verdana;text-align:left;width:720px;padding-left:5px;">
                    <div style="float:left;width:680px;">
                        <div style="font-size:12px;font-weight:bold;">Consultant Name:</div>
                        <div style="font-size:30px;"><?php echo $user->getProfileLastName() . ", " . $user->getProfileFirstName();?></div>
                    </div>
                    <div style="float:left;padding-top:10px;width:680px;">
                        <div style="font-size:12px;font-weight:bold;">Name of Company:</div>
                        <div style="font-size:24px;"><?php echo $user->getCompanyName();?></div>
                    </div>
                    <div style="float:left;padding-top:10px;width:680px;">
                        <div style="float:left;">
                            <div style="font-size:12px;font-weight:bold;padding-bottom:5px;">Mailing Address:</div>
                            <div style="border: 1px solid #CCCCCC;background-color:#F2F5F9;padding:5px;">
                                <table border="0"
                                       cellpadding="0"
                                       cellspacing="0"
                                       style="font-family:Verdana;font-size:12px;font-weight:normal;width:300px;">
                                    <tbody>
                                        <tr>
                                            <td id="mailingStreetLabel"
                                                colspan="3"
                                                style="padding-bottom:2px;padding-top:0px;padding-left:5px;font-weight:bold;">Street:</td>
                                        </tr>
                                        <tr>
                                            <td colspan="3" style="padding-left:5px;">
                                                <?php echo $user->getMailingAddress();?>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td id="mailingCityLabel"
                                                style="padding-bottom:2px;padding-top:3px;padding-left:5px;font-weight:bold;">
                                                City:
                                            </td>
                                            <td id="mailingStateIdLabel"
                                                style="padding-bottom:2px;padding-top:3px;padding-left:5px;font-weight:bold;">
                                                State:
                                            </td>
                                            <td id="mailingZipCodeLabel"
                                                style="padding-bottom:2px;padding-top:3px;padding-left:5px;font-weight:bold;">
                                                Zip Code:
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding-left:5px;">
                                                <?php echo $user->getMailingCity();?>
                                            </td>
                                            <td style="padding-left:5px;">
                                                <?php echo MiscellaneousManager::getStateName($user->getMailingStateId()); ?>
                                            </td>
                                            <td style="padding-left:5px;">
                                                <?php echo (($user->getMailingZipCode() == "0")) ? "00000" : $user->getMailingZipCode(); ?>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div style="float:right;">
                            <div style="font-size:12px;font-weight:bold;padding-bottom:5px;">Physical Address:</div>
                            <div style="border: 1px solid #CCCCCC;background-color:#F2F5F9;padding:5px;">
                                <?php
                                if (($user->getPhysicalAddress() == "") ||
                                    ($user->getPhysicalCity() == "") ||
                                    ($user->getPhysicalStateId() == "") ||
                                    ($user->getPhysicalZipCode() == "")) {

                                    ?>
                                <div style="text-align:center;font-family:Verdana;font-size:12px;font-weight:normal;width:300px;height:70px;">
                                    <br />Not Provided
                                </div>
                                <?php
                                } else {
                                    ?>
                                <table border="0"
                                       cellpadding="0"
                                       cellspacing="0"
                                       style="font-family:Verdana;font-size:12px;font-weight:normal;width:300px;">
                                    <tbody>
                                        <tr>
                                            <td id="physicalStreetLabel"
                                                colspan="3"
                                                style="padding-bottom:2px;padding-top:0px;padding-left:5px;font-weight:bold;">Street:</td>
                                        </tr>
                                        <tr>
                                            <td colspan="3" style="padding-left:5px;">
                                                    <?php echo $user->getPhysicalAddress();?>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td id="physicalCityLabel"
                                                style="padding-bottom:2px;padding-top:3px;padding-left:5px;font-weight:bold;">
                                                City:
                                            </td>
                                            <td id="physicalStateIdLabel"
                                                style="padding-bottom:2px;padding-top:3px;padding-left:5px;font-weight:bold;">
                                                State:
                                            </td>
                                            <td id="physicalZipCodeLabel"
                                                style="padding-bottom:2px;padding-top:3px;padding-left:5px;font-weight:bold;">
                                                Zip Code:
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="padding-left:5px;">
                                                    <?php echo $user->getPhysicalCity();?>
                                            </td>
                                            <td style="padding-left:5px;">
                                                    <?php echo MiscellaneousManager::getStateName($user->getPhysicalStateId()); ?>
                                            </td>
                                            <td style="padding-left:5px;">
                                                    <?php echo (($user->getPhysicalZipCode() == "0")) ? "00000" : $user->getPhysicalZipCode(); ?>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                                <?php
                                }
                                ?>
                            </div>
                        </div>
                    </div>
                    <div style="padding-top:10px;float:left;width:680px;">
                        <div style="float:left;width:300px;">
                            <div style="font-size:12px;font-weight:bold;padding-bottom:2px;">Business Phone:</div>
                            <div style="font-size:12px;">
                                <?php echo $user->getTelephone();?><?php echo ($user->getTelephoneExt() == "") ? "" : " Ext. " . $user->getTelephoneExt() ?>
                            </div>
                        </div>
                        <div style="float:right;width:310px;">
                            <div style="font-size:12px;font-weight:bold;padding-bottom:2px;">Cell Phone:</div>
                            <div style="font-size:12px;">
                                <?php echo (($user->getCellphone() == "")) ? "Not Provided" : $user->getCellphone(); ?>
                            </div>
                        </div>
                    </div>
                    <div style="padding-top:10px;float:left;width:680px;">
                        <div style="float:left;width:300px;">
                            <div style="font-size:12px;font-weight:bold;">Email Address:</div>
                            <div style="font-size:12px;"><?php echo $user->getProfileEmail();?></div>
                        </div>
                        <div style="float:right;width:310px;">
                            <div style="font-size:12px;font-weight:bold;">Website Address:</div>
                            <div style="font-size:12px;">
                                <?php echo (($user->getWebsite() == "")) ? "Not Provided" : $user->getWebsite(); ?>
                            </div>
                        </div>
                    </div>
                    <div style="padding-top:10px;float:left;">
                        <div style="font-size:12px;font-weight:bold;padding-bottom:2px;">Services Offered:</div>
                        <div style="padding:10px;border:1px solid #CCCCCC;">
                            <div style="font-size:12px;padding:0px;">
                                <table class="consultantProvidedServicesTable" style="width:660px;">
                                    <thead>
                                        <tr>
                                            <th>Service</th>
                                            <th>Serving Since</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                        $consultantServices = $user->getServices();
                                        for ($i = 0 ; $i < count($consultantServices) ; $i++) {
                                            $tempService = $consultantServices[$i];

                                            $tempServiceSinceParseDate = explode("-", $tempService->getServingSince());

                                            $tempServingSince = $months[$tempServiceSinceParseDate[1]] . ", " . $tempServiceSinceParseDate[0];

                                            if (($i % 2) == 0) {
                                                ?>
                                        <tr>
                                            <td><?php echo $tempService->getServiceName(); ?></td>
                                            <td><?php echo $tempServingSince; ?></td>
                                        </tr>
                                            <?php
                                            } else {
                                                ?>
                                        <tr style="background-color:#F2F5F9;">
                                            <td><?php echo $tempService->getServiceName(); ?></td>
                                            <td><?php echo $tempServingSince; ?></td>
                                        </tr>
                                            <?php
                                            }
                                        }
                                        ?>
                                    </tbody>
                                </table>
                            </div>
                            <div style="padding-top:10px;">
                                <div style="font-size:12px;font-weight:bold;padding-bottom:2px;">Services Offered Description:</div>
                                <div style="font-size:12px;padding:5px;border:1px solid #CCCCCC;width:660px;">
                                    <?php echo $user->getServicesOfferedDescription();?>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div style="padding-top:10px;float:left;">
                        <div style="font-size:12px;font-weight:bold;padding-bottom:2px;">Provided Services To:</div>
                        <div style="font-size:12px;padding:5px;border:1px solid #CCCCCC;width:680px;">
                            K-12 (e.g., ISDs, private schools): <?php echo ($user->getK12ClienteleIndicator() == "1") ? '<span style="color:green;font-weight:bold;">YES</span>' : '<span style="color:red;font-weight:bold;">NO</span>'; ?>
                            <br /><br />
                            Higher Education (e.g., junior colleges) : <?php echo ($user->getHigherEducationClienteleIndicator() == "1") ? '<span style="color:green;font-weight:bold;">YES</span>' : '<span style="color:red;font-weight:bold;">NO</span>'; ?>
                        </div>
                    </div>
                    <div style="padding-top:10px;float:left;">
                        <div style="font-size:12px;font-weight:bold;padding-bottom:2px;">Background:</div>
                        <div style="font-size:12px;padding:5px;border:1px solid #CCCCCC;width:680px;">
                            <?php echo $user->getBackgroundDescription();?>
                        </div>
                    </div>
                    <div style="padding-top:10px;float:left;">
                        <div style="font-size:12px;font-weight:bold;padding-bottom:2px;">Education:</div>
                        <div style="font-size:12px;padding:5px;border:1px solid #CCCCCC;width:680px;">
                            <?php echo $user->getEducationDescription();?>
                        </div>
                    </div>
                    <div style="padding-top:10px;float:left;">
                        <div style="font-size:12px;font-weight:bold;padding-bottom:2px;">Experience:</div>
                        <div style="font-size:12px;padding:5px;border:1px solid #CCCCCC;width:680px;">
                            <?php echo $user->getExperienceDescription();?>
                        </div>
                    </div>
                    <div style="padding-top:10px;padding-bottom:20px;float:left;">
                        <div style="font-size:12px;font-weight:bold;padding-bottom:2px;">Complaints and / or Litigation:</div>
                        <div style="font-size:12px;padding:5px;border:1px solid #CCCCCC;width:680px;">
                            Please contact this consultant for more information regarding any pending complaints or litigation.
                            <br /><br />
                            Complaints: <?php echo ($user->getComplaintIndicator() == "1") ? '<span style="color:green;font-weight:bold;">YES</span>' : '<span style="color:red;font-weight:bold;">NO</span>'; ?>
                            <br /><br />
                            Litigation: <?php echo ($user->getPendingLitigationIndicator() == "1") ? '<span style="color:green;font-weight:bold;">YES</span>' : '<span style="color:red;font-weight:bold;">NO</span>'; ?>
                        </div>
                    </div>
                </div>
            </td>
        </tr>
    </tbody>
</table>
<script>
    window.print();
</script>